home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: Michael Smith <msmith@mpx.com.au>
- Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
- Subject: Re: C coding problem
- Date: 6 Apr 1996 08:51:39 -0600
- Organization: Emmenjay Consulting
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4k60dr$abu@solutions.solon.com>
- References: <4ianbf$h86@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j06na$808@solutions.solon.com> <4jttan$3gf@solutions.solon.com> <4jv7n3$d8o@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Kazimir Kylheku wrote:
- > Niall Smart <nsmart@indigo.ie> wrote:
- > >
- > >>: I recently wrote a loop that went like this:
- > >
- > >>: while (p < end_p)
- > >>: ++*p++;
- > I wouldn't hire a C maintainer who didn't know the basic
- > precedence rules of the C language sufficiently well to
- > know what ++*p++ does,
-
- Given an unlimited pool of applicants and an unlimited budget,
- neither would I.
-
- In the real world, people are not always hired for their impeccable
- skills. I don't have any say in who gets hired by my clients. Often
- they are just out of Uni and expected to learn the finer points of
- programming as they go. I'm not saying that this is a good idea, simply
- that it happens.
-
- Considerations of programmer experience aside, an expression like:
- while (p < end_p)
- ++*p++;
- is fairly unusual these days.
-
- If you learned programming in the bad old days when every byte was
- critical and compiler optimization was ineffective, you saw lots of code
- like that (and much worse).
-
- If you learned programming in the last five years, you may have never
- seen such a piece of code. I agree that you should be able to figure it
- out, but it adds complexity to the code and makes an error more likely.
-
- If you can make your code as simple and self evident as possible, the
- programmer can concentrate more effort on the algorithm, and that must
- help.
-
- I suggest that the code segment:
- for ( ; p<end_p; p++)
- ++(*p);
- is far easier to read.
-
- Programmers make enough errors as it is. Let's not make it any harder
- than it needs to be.
-
- --
- #####################################################################
- Michael Smith msmith@mpx.com.au
- Emmenjay Consulting http://www.hutch.com.au/~emmenjay
- #####################################################################
-